#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import base64
import json


def Base64EnDecoder(xorArray="win-sky"):
    return list(bytearray(xorArray.encode("utf-8")))


def encodeDataInfo(srcData):
    xorArray = Base64EnDecoder()
    srcInfo = list(srcData.encode("utf-8"))
    for i in range(len(srcInfo)):
        for j in range(len(xorArray)):
            srcInfo[i] = srcInfo[i] ^ xorArray[j]
    baseStr = base64.b64encode(bytes(srcInfo))
    return baseStr


def decodeDataInfo(dicData):
    xorArray = Base64EnDecoder()
    dicInfo = list(base64.b64decode(dicData.encode("utf-8")))
    for i in range(len(dicInfo)):
        for j in range(len(xorArray)):
            dicInfo[i] = dicInfo[i] ^ xorArray[j]
    dicInfo = bytes(dicInfo)
    return dicInfo.decode(encoding="unicode-escape")


raw_dict = {"msg":"当前操作需要登录！","data":"","resultCode":"702"}
raw_data = json.dumps(raw_dict)

base_string = encodeDataInfo(raw_data)
print(base_string)
base_bytes = base_string.decode('utf-8')
print(decodeDataInfo(base_bytes))
